package com.cby.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * 重定向
 */
@Controller
@RequestMapping("/redirect")
public class RedirectController {

    @RequestMapping("/hello.action")
    public String hello(HttpServletRequest request){
        System.out.println("test....");
        //request.setAttribute("name","Jason"); // 指定Model的值
        //return "/index.jsp";
        return "/demo";
    }

    /**
     * 实现转发
     */
    @RequestMapping("/hello11.action")
    public String hello11(HttpServletRequest request){
        request.setAttribute("name", "cjj");
        return "forward:hello.action";
    }

    /**
     * 实现重定向
     */
    @RequestMapping("/hello12.action")
    public String hello12(HttpServletRequest request){
        request.setAttribute("name", "cjj");
        return "redirect:/hello.action";
    }
}
